package com.huike.clues.service.impl;


import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.domain.TbClue;
import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.TbClueMapper;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.ITbClueTrackRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 线索跟进记录Service业务层处理
 * @date 2022-04-22
 */
@Service
@Transactional
public class TbClueTrackRecordServiceImpl implements ITbClueTrackRecordService {
    @Autowired
    private TbClueTrackRecordMapper tbClueTrackRecordMapper;

    /**
     * 查询状态为伪线索跟进记录总数
     *
     * @return
     */
    @Override
    public int findByClueId(Long clueId) {
        return tbClueTrackRecordMapper.findByClueId(clueId);
    }
   /* @Autowired
    private TbClueMapper tbClueMapper;
    @Autowired
    private TbClueTrackRecordMapper tbClueTrackRecordMapper;*/
    /**
     * 新增线索跟进记录
     * @param tbClueTrackRecord
     * @return
     */
    /*public int addClueTrackRecord(ClueTrackRecordVo tbClueTrackRecord){
        // 1.更新线索表数据
        TbClue tbClue1 = new TbClue();
        BeanUtils.copyProperties(tbClueTrackRecord,tbClue1);
        tbClue1.setId(tbClueTrackRecord.getClueId());
        tbClue1.setStatus(TbClue.StatusType.FOLLOWING.getValue());
        
        tbClueMapper.updateTbClue(tbClue1);
        
    
        // 2.新增线索记录表数据
        TbClueTrackRecord tbClueTrackRecord1 = new TbClueTrackRecord();
        BeanUtils.copyProperties(tbClueTrackRecord,tbClueTrackRecord1);
        tbClueTrackRecord1.setCreateTime(DateUtils.getNowDate());
        tbClueTrackRecord1.setCreateBy(SecurityUtils.getUsername());
      
        int row = tbClueTrackRecordMapper.addClueTrackRecord(tbClueTrackRecord1);
    
        return row;
    }*/
    
    /**
     * 查询线索记录
     *
     * @param clueId
     */
 /*   @Override
    public List<TbClueTrackRecord> findClueTrackRecord(Long clueId) {
        
        // 1.查询线索表
        List<TbClueTrackRecord> clueTrackRecord = tbClueTrackRecordMapper.findClueTrackRecord(clueId);
        // 2.返回结果
        return clueTrackRecord;
    }*/
    
    
}
